{% import "header.html" as header %}

{{ header.notebookerHeader(readonly_mode, scheduler_disabled) }}

<html>
<body>
    {{ header.sidebar(all_reports) }}

    <!-- Right sidebar  -->
    <div class="resultsHomepage">

        <div class="ui fluid container leftResult">
                <h1 class="ui header resultHeader">Results: {{ result.report_title }}</h1>
                <div class="ui container" id="resultsContainer">
                    <div class="">
                        <div class="ui active inverted dimmer iframeLoadingDimmer">
                            <div class="ui text loader">Loading</div>
                        </div>
                        <iframe
                                id="resultsIframe"
                                src="{{ result_url }}"
                                style="width:100%; border:none;"
                                onload="iframeLoaded(this)"
                                class="iframeToLoad"
                                scrolling="no">
                        </iframe>
                    </div>
                </div>

                <br/>
                <br/>
                <br/>
            </div>
            <div class="metadataSidebar rightResult">
                <button onclick="viewFullscreen('{{ fullscreen_url }}')"
                            type="button" class="ui green button"><i class="expand alternate icon"></i>Fullscreen Results</button>
                <br/>
                <br/>
                {% if result.status == donevalue %}
                    <button onclick="location.href='{{ ipynb_url }}'"
                                type="button" class="ui green button"><i class="download icon"></i>as .ipynb</button>
                    <br/>
                    <br/>
                    {% if result.pdf %}
                        <button onclick="location.href='{{ pdf_url }}'"
                                    type="button" class="ui green button"><i class="download icon"></i>as .pdf</button>
                        <br/>
                        <br/>
                    {% endif %}
                    <button id="stdoutButton" onclick="viewStdout('{{ stdout_url }}')"
                            type="button" class="ui green button"><i class="eye icon"></i>View Stdout</button>
                {% endif %}
                <h4>Report was submitted at:</h4> {{result.job_start_time}}
                {% if result.job_finish_time %}
                        <h4>It finished at:</h4>  {{result.job_finish_time}}
                {% endif %}
                <h4>Job ID:</h4> {{ job_id }}
                <h4>Report Template Name:</h4> {{ report_name }}
                {% if result.mailto %}
                    <h4>Mailing results to:</h4> {{ result.mailto }}
                {% endif %}
                {% if result.error_mailto %}
                    <h4>Mailing errors to:</h4> {{ result.error_mailto }}
                {% endif %}
                {% if result.mailfrom %}
                    <h4>Mailing results from:</h4> {{ result.mailfrom }}
                {% endif %}
                {% if result.email_subject %}
                    <h4>Email subject:</h4> {{ result.email_subject }}
                {% endif %}
                {% if result.overrides %}
                    <h4>Parameters:</h4>
                    <div class="ui list">
                        {% for k, v in result.overrides|dictsort() %}
                            <li class="item">{{ k }} = {{ v }}</li>
                        {% endfor %}
                    </div>
                {% endif %}
                <br/>
                <br/>
                {% if not readonly_mode %}
                    <button onclick="rerunReport('{{ result.job_id }}', '{{ rerun_url }}')"
                                type="button" class="ui blue button rerunButton"><i class="redo alternate icon"></i>Rerun</button>
                    <br/>
                    <br/>
                    <button onclick="cloneReport('{{ clone_url }}')"
                                type="button" class="ui blue button cloneButton"><i class="copy outline icon"></i>Clone Parameters</button>
                    <br/>
                    <br/>
                {% endif %}

            </div>




        <!-- Stdout modal -->
                <div class="ui modal" style="width: 50%; height: 70%;" id="stdoutModal">
                  <div class="header">Stdout</div>
                  <div class="content" style="width: 100%; height: 100%; overflow: scroll">
                    <code id="stdoutContent"></code>
                  </div>
                  <div class="actions">
                    <div class="ui ok button blue">Copy</div>
                    <div class="ui cancel button red">Close</div>
                  </div>
                </div>
            </div>

</body>
</html>
